USE [NANS21V]
GO

/****** オブジェクト: SqlProcedure [dbo].[Kyogibetu] スクリプト日付: 2014/05/02 11:41:41 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Kyogibetu]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Kyogibetu]
GO

CREATE PROCEDURE [dbo].[Kyogibetu]
	@TAIKAINO int
AS
	
	SELECT 
		TK.SYUMOKUNO, 
		TK.KYOGINO, 
		TK.SYUBETUNO, 
		TK.SEIBETUNO, 
		TK.KYOGIMEI, 
		TK.KYOGIKANA, 
		TS.KIROKUKUBUN, 
		TS.SYUMOKUKUBUN, 
		TK.GATTAIFLG 
	FROM 
		TBL_KYOGI AS TK, 
		TBL_SYUMOKU_MASTER AS TS, 
		TBL_SYUBETU AS SB 
	WHERE 
		TK.SYUMOKUNO = TS.SYUMOKUNO 
		AND TK.SYUBETUNO = SB.SYUBETUNO 
		AND TK.TAIKAINO = @TAIKAINO
		AND TK.GATTAIFLG <> 2 
	ORDER BY TK.SEIBETUNO, 
		SB.PRINTNO, 
		TS.PRINTNO
